<template>
	<vk-data-dialog
		v-model="value.show"
		:title="page.title"
		:top="page.top"
		:width="page.width"
		:close-on-click-modal="true"
		mode="form"
		@open="onOpen"
		@closed="onClose"
	>
		<!-- 页面主体内容开始 -->
		<vk-data-form
			ref="form1"
			v-model="form1.data"
			:form-type="value.mode"
			:rules="form1.props.rules"
			:action="form1.props.action"
			:columns="form1.props.columns"
			:loading.sync="form1.props.loading"
			:labelWidth="form1.props.labelWidth"
			:show-cancel="page.showCancel"
			:cancel-text="page.cancelText"
			:submit-text="page.submitText"
			@success="onFormSuccess"
		>
			<template v-slot:footer="{ loading }">
				<view style="text-align: center;" >
					<el-button :loading="loading" type="danger"  size="small" style="padding: 10px 40px;margin-right: 30px; " @click="adopt(4)"> 拒绝 </el-button>
					<el-button :loading="loading" type="success" size="small" style="padding: 10px 40px; " @click="adopt(2)"> 通过 </el-button>
				</view>
			</template>
		</vk-data-form>
		<!-- 页面主体内容结束 -->
	</vk-data-dialog>
</template>

<script>
var that; // 当前页面对象
var vk = uni.vk; // vk实例
export default {
	props: {
		value: {
			Type: Object,
			default: function() {
				return {
					show: false,
					mode: "",
					item: {}
				};
			}
		}
	},
	data: function() {
		// 组件创建时,进行数据初始化
		return {
			page: {
				title: "审核",
				submitText: "确定",
				cancelText: "关闭",
				showCancel: true,
				top: "7vh",
				width: "500px"
			},
			form1: {
				// 表单请求数据，此处可以设置默认值
				data: {},
				// 表单属性
				props: {
					loading:false,
					// 表单请求地址
					action:"admin/business/sys.withdrawal.examine",
					// 表单字段显示规则
					columns:[
						{ key:"user_id", title:"用户ID", type:"remote-select", placeholder:"请输入用户ID", width:290,
							action:"admin/select/kh/user", disabled:true
						},
						{ key:"status", title:"状态", type:"select", width:290,
							data:[
								{ value:-1, label: "已被删除" },
								{ value: 0, label: "待提现" },
								{ value: 1, label: "提现中" },
								{ value: 2, label: "已提现" },
								{ value: 3, label: "提现取消" },
								{ value: 4, label: "拒绝提现" },
						 ],
						 disabled:true
						},
						{ key:"mode", title:"提现类型", type:"radio", width:290,
						  data:[
								{ value: 0, label: "普通提现" },
								{ value: 1, label: "急速提现" },
							],
							tips: "普通提现：手动转账<br/>急速提现：自动转账（不支持转银行卡）"
						},
						{ key:"comment", title:"用户备注", type:"textarea", width:290,
							maxlength:200,
							showWordLimit:true,
							autosize:{ minRows: 3, maxRows: 10 },
							disabled:true,
						},
						{ key:"seller_remark", title:"商家审核备注", type:"textarea", width:290,
							maxlength:200,
							showWordLimit:true,
							autosize:{ minRows: 3, maxRows: 10 },
						},
					],
					// 表单验证规则
					rules:{

					},
					// 左侧label的宽度
					labelWidth: "100px",
				}
			}
		};
	},
	mounted() {
		that = this;
		that.init();
	},
	methods: {
		// 初始化
		init() {
			let { value } = that;
			that.$emit("input", value);
		},
		// 监听 - 页面打开
		onOpen() {
			that = this;
			let { item={} } = that.value;
			// 每次打开时，重新设置表单的值 = value.item 的值，item通过 vk.pubfn.openForm('表单名',{ item:{ _id:"1" } }) 传递值
			that.form1.data = vk.pubfn.copyObject(item);
		},
		// 监听 - 页面关闭
		onClose() {
			//that.$refs.form1.resetForm(); // 关闭时，重置表单
		},
		// 监听 - 提交成功后
		onFormSuccess() {
			that.value.show = false; // 关闭页面
			that.$emit("success");
		},
		// 审核通过执行的方法
		adopt(status){
			that.$refs.form1.submitForm({
				data:{
					status:status
				},
				success: (data) => {
					that.$set(that.value.item,"status",status);
					that.$set(that.value.item,"seller_remark",that.form1.data.seller_remark);
				},
				fail: (data) => {
					that.value.show = false;
				}
			});
		},
	},
	watch: {

	},
	// 计算属性
	computed: {}
};
</script>

<style lang="scss" scoped></style>
